package com.es.servlet; /**
 * 描述:
 * es-jsp-
 *
 * @author Derek
 * 创建时间：2022-04-27 11:09
 */

import com.es.bean.Student;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@WebServlet(name = "ListServlet", value = "/list")
public class ListServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Map<String, Student> map = new HashMap<>();

        //
        List<Student> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            Student student = new Student();
            student.setId(i);
            student.setName("小白"+i+"号");
            list.add(student);
            map.put("s"+(i+1)+"", student);
        }


        request.setAttribute("stus", list);
        request.setAttribute("myMap", map);
        request.getRequestDispatcher("list.jsp").forward(request,response);
    }


}
